package com.oguzhan.xtools.view;

import javax.swing.JPanel;
import javax.swing.JSplitPane;
import java.awt.BorderLayout;
import javax.swing.JList;
import net.miginfocom.swing.MigLayout;
import java.awt.Dimension;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.AbstractListModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.ImageIcon;

public class MockView extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2735689232917800258L;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTable table;
	private JTextField textField_4;
	private JTextField textField_5;

	/**
	 * Create the panel.
	 */
	public MockView() {
		setBorder(new EmptyBorder(5, 5, 5, 5));
		setPreferredSize(new Dimension(800, 600));
		setLayout(new BorderLayout(0, 0));
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setBorder(null);
		splitPane.setDividerSize(1);
		add(splitPane);
		
		JPanel mockPanel = new JPanel();
		splitPane.setLeftComponent(mockPanel);
		mockPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new TitledBorder(null, "Mock List", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		mockPanel.add(panel_2, BorderLayout.CENTER);
		panel_2.setLayout(new BorderLayout(0, 0));
		
		JList list = new JList();
		list.setModel(new AbstractListModel() {
			/**
			 * 
			 */
			private static final long serialVersionUID = -8596835691086111921L;
			String[] values = new String[] {"RetailLoanApplication", "RetailLoanApplication", "RetailLoanApplication"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		list.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
		panel_2.add(list);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new TitledBorder(null, "Config", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		splitPane.setRightComponent(panel_1);
		panel_1.setLayout(new MigLayout("", "[][368.00,grow]", "[][][][][grow 50,top][][grow][]"));
		
		JLabel lblMockName = new JLabel("Mock Name");
		panel_1.add(lblMockName, "cell 0 0,alignx trailing");
		
		textField = new JTextField();
		panel_1.add(textField, "cell 1 0,growx");
		textField.setColumns(10);
		
		JLabel lblPort = new JLabel("Port");
		panel_1.add(lblPort, "cell 0 1,alignx trailing");
		
		textField_1 = new JTextField();
		panel_1.add(textField_1, "cell 1 1,growx");
		textField_1.setColumns(10);
		
		JLabel lblPath = new JLabel("Endpoint");
		panel_1.add(lblPath, "cell 0 2,alignx trailing");
		
		textField_2 = new JTextField();
		panel_1.add(textField_2, "cell 1 2,growx");
		textField_2.setColumns(10);
		
		JLabel lblMethod = new JLabel("Method");
		panel_1.add(lblMethod, "cell 0 3,alignx trailing");
		
		textField_3 = new JTextField();
		panel_1.add(textField_3, "cell 1 3,growx");
		textField_3.setColumns(10);
		
		JLabel lblResponseHeader = new JLabel("Response Header");
		panel_1.add(lblResponseHeader, "cell 0 4");
		
		table = new JTable();
		panel_1.add(table, "cell 1 4,grow");
		
		JLabel lblHeaderParameter = new JLabel("Header Parameter");
		panel_1.add(lblHeaderParameter, "cell 0 5,alignx trailing");
		
		textField_4 = new JTextField();
		panel_1.add(textField_4, "flowx,cell 1 5");
		textField_4.setColumns(10);
		
		JLabel label = new JLabel(":");
		panel_1.add(label, "cell 1 5");
		
		textField_5 = new JTextField();
		panel_1.add(textField_5, "cell 1 5");
		textField_5.setColumns(10);
		
		JButton btnAdd = new JButton("");
		btnAdd.setIcon(new ImageIcon(MockView.class.getResource("/tr/com/softtech/icons/oxygen/action_vote_plus.png")));
		panel_1.add(btnAdd, "cell 1 5");
		
		JButton btnRemove = new JButton("");
		btnRemove.setIcon(new ImageIcon(MockView.class.getResource("/tr/com/softtech/icons/oxygen/action_vote_minus.png")));
		panel_1.add(btnRemove, "cell 1 5");
		
		JLabel lblResponseBody = new JLabel("Response Body");
		panel_1.add(lblResponseBody, "cell 0 6");
		
		JTextArea textArea = new JTextArea();
		panel_1.add(textArea, "cell 1 6,grow");
		
		JButton btnSave = new JButton("Save");
		panel_1.add(btnSave, "flowx,cell 1 7,alignx right");
		
		JButton btnCancel = new JButton("Cancel");
		panel_1.add(btnCancel, "cell 1 7");
		splitPane.setDividerLocation(300);

	}

}
